package print;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;

/*
PrintStream的基本使用:
1.创建对象关联文件
    public PrintStream(OutputStream os)
    public PrintStream(File f)
    public PrintStream(File f，String 编码方式)
    public PrintStream(String filePath)
    public PrintStream(String filePath，String 编码方式)
    追加写入：PrintStream ps = new PrintStream(new FileOutputStream("E:\\A.txt",true));

2.写出方法
    write():写出一个字节，不建议使用，无法原样写入
    print():原样写入，不带换行
    println():原样写入，带换行

 */
public class PrintStreamDemo2 {
    public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException {
        //指定编码方式写出
        PrintStream ps = new PrintStream("E:\\changeFile.txt","gbk");
        ps.println("大家好");
        ps.close();
    }

    private static void method1() throws FileNotFoundException {
        PrintStream ps = new PrintStream("HDay09\\B.txt");
        ps.write(97);
        ps.print(97);
        ps.println(98);
        ps.println(true);
        ps.close();
    }
}
